// Copyright(c) 2008 Tri Tech Information Systems Inc. 
// Distributed under the Boost Software License, Version 1.0.
//     (See accompanying file ../LICENSE_1_0.txt or copy at
//           http://www.boost.org/LICENSE_1_0.txt)
//     
#include <boost/python.hpp>
#include <pyxx/util.h>
#include <pyxx/arg.h>
#include <iostream>
#include "version.h"
using namespace boost::python;

void InstallPointerSystem();
void WrapException();
void defarg_expose();

struct cpp_namespace
{
};

BOOST_PYTHON_MODULE( pyxx_helper )
{
    try
    {
        defarg_expose();
        InstallPointerSystem();
        WrapException();

        scope s;
        s.attr("__version__") = version_text;
        s.attr("__namespaces__") = dict();

        class_<cpp_namespace>("cpp_namespace");
    }
    catch(boost::python::error_already_set&)
    {
        PyObject * new_type;
        PyObject * new_val;
        PyObject * new_tb;
        PyErr_Fetch( &new_type, &new_val, &new_tb );
        PyObject * err = PyObject_Str(new_val);
        std::string error = PyString_AsString( err);
        Py_DECREF(err);
        Py_XDECREF(new_type);
        Py_XDECREF(new_val);
        Py_XDECREF(new_tb);

        std::cerr << error << std::endl;
    }
}
